<?php

require 'functions.php';
require_once '../data/data.php';
header("Content-type:text/html;charset=utf-8");

$id =  $_POST['id'];
$Number = input('Number');
$Name = input('Name');
$IDcard = input('IDcard',18);
$Gender = input('Gender',1);
$Birth = input('Birth','1995-01-01');
$Grade = input('Grade',1);
$University = input('University','华侨大学');
$School = input('School','信息学院');
$Major = input('Major','电子信息工程');
$GPA = input('GPA',3.00);
$description = input('describ');

if (empty($Number)) {
	error("学号不能为空","../stu_info.php?op=2&id=");
	return;
}

if (empty($Name)) {
	error("请输入姓名","../stu_info.php?op=2&id=$id");
	return;
}

if (empty($IDcard)) {
	error("请输入身份证","../stu_info.php?op=2&id=$id");
	return;
}

$sql = "update students set Number=?,Name=?,IDcard=?,Gender=?,Birth=?,Grade=?,University=?,School=?,Major=?,GPA=?,Introduction=? where id=?";
$args = [$Number,$Name,$IDcard,$Gender,$Birth,$Grade,$University,$School,$Major,$GPA,$description,$id];
if (execute($sql, $args)) {
   success('修改学生信息成功','../index.php');
} else {
   error('修改学生信息失败',"../stu_info.php?op=2&id=$id");
}